<?php global $data; ?>
<?php get_header(); ?>

<!-- BEGIN #main-content -->
<div <?php echo sidebar_position('primary-content'); ?>>

	<?php /* ----------------------------------------------------
			Slideshow Loop
	------------------------------------------------------- */ ?>
	
	<?php if( $data['slideshow_display'] ) { ?>
		
		<?php $slide_limit = ''; ?>
		<?php $slide_cat = ''; ?>
		
		<?php if( $data['slideshow_max_slides'] ) { $slide_limit = '&posts_per_page=' . $data['slideshow_max_slides']; } ?>
		<?php if( $data['slideshow_category'] ) { $slide_cat = '&cat=' . $data['slideshow_category']; } ?>
		
		<?php query_posts( "post_type=post" . $slide_limit . $slide_cat ); ?>
		<?php if ( have_posts() ) : ?>
			<div class="slider clearfix">
				<ul class="slides">
					<?php while ( have_posts() ) : the_post(); ?>
						<?php get_template_part( 'loop', 'style3' ); ?>
					<?php endwhile; ?>
				</ul>
			</div>
		<?php endif; ?>
		<div class="clearboth"></div>
	
	<?php } ?>
	
	<?php /* ----------------------------------------------------
			Two Large Columns Loop
	------------------------------------------------------- */ ?>
	
	<?php if( $data['home2cols_display'] ) { ?>
		
		<?php $home2cols_col1_cat = ''; ?>
		<?php $home2cols_col2_cat = ''; ?>
		
		<?php if( $data['home2cols_col1_cat'] ) { $home2cols_col1_cat = '&cat=' . $data['home2cols_col1_cat']; } ?>
		<?php if( $data['home2cols_col2_cat'] ) { $home2cols_col2_cat = '&cat=' . $data['home2cols_col2_cat']; } ?>
		
		<ul class="news-block-columns-2 clearfix">

			<?php query_posts( "post_type=post&posts_per_page=1" . $home2cols_col1_cat ); ?>
			<?php if ( have_posts() ) : ?>
					<?php while ( have_posts() ) : the_post(); ?>
						<?php get_template_part( 'loop', 'style6' ); ?>
					<?php endwhile; ?>
			<?php endif; ?>
			
			<?php query_posts( "post_type=post&posts_per_page=1" . $home2cols_col2_cat ); ?>
			<?php if ( have_posts() ) : ?>
					<?php while ( have_posts() ) : the_post(); ?>
						<?php get_template_part( 'loop', 'style6' ); ?>
					<?php endwhile; ?>
			<?php endif; ?>
	
		</ul>
	
	<?php } ?>
	
	<?php /* ----------------------------------------------------
			Five Small Columns Loop
	------------------------------------------------------- */ ?>
	
	<?php if( $data['home5cols_display'] ) { ?>
		
		<?php $home5cols_cat = ''; ?>
		<?php $home5cols_limit = ''; ?>
		
		<?php if( $data['home5cols_cat'] ) { 
			$home5cols_cat = '&cat=' . $data['home5cols_cat']; 
			$thecat = get_category($data['home5cols_cat']);
			$category_name1 = $thecat->name;
		} else {
			$category_name1 = __('All','qns');
		} ?>
		
		<?php if( $data['home5cols_limit'] ) { $home5cols_limit = '&posts_per_page=' . $data['home5cols_limit']; } ?>
		
		<div class="title-block">
			<h3>Nuestros Profesionales</h3>
                        <a class="title-link" href="<?php bloginfo('url'); ?>/profesionales">Ver todos</a>
		</div>

		<?php query_posts( "post_type=staff" . $home5cols_cat . $home5cols_limit ); ?>
		<?php if ( have_posts() ) : ?>
			<ul class="news-block-columns-5 clearfix">
				<?php while ( have_posts() ) : the_post(); ?>
					<?php get_template_part( 'loop', 'index-staff' ); ?>
				<?php endwhile; ?>
			</ul>
		<?php endif; ?>
	
	<?php } ?>
	
	
	
	<?php /* ----------------------------------------------------
			Shop Loop
	------------------------------------------------------- */ ?>
	
	<?php if(is_plugin_active('woocommerce/woocommerce.php')) { ?>
                

	                
	<?php 
        
                if( $data['shop_display'] ) {

                    if( $data['homeshop_title'] ) { $homeshop_title = $data['homeshop_title']; } else { $homeshop_title = __('Our Shop','qns'); }

                    $args = array(  
                        'post_type' => 'product',  
                        'meta_key' => '_featured',  
                        'meta_value' => 'yes',  
                        'posts_per_page' => 4  
                    );  

                    $featured_query = new WP_Query( $args );  

                    if ($featured_query->have_posts()) :    
        ?>
                        <div class="title-block">
                                <h3><?php echo $homeshop_title; ?></h3>
                                <a class="title-link" href="<?php bloginfo('url'); ?>/store">Ver tienda</a>
                        </div>
                        <div class="featured-products-4">
                            <div class="woocommerce columns-4">
                                <ul class="products">
                                    <?php
                                        while ($featured_query->have_posts()) :   
                                            $featured_query->the_post();  
                                            $product = get_product( $featured_query->post->ID );  
                                    ?>
                                        <li>
                                            <div class="product-thumbnail-wrapper">		
                                                <a href="<?php the_permalink(); ?>">
                                                    <?php do_action( 'woocommerce_before_shop_loop_item_title' ); ?>
                                                </a>
                                            </div>
                                            <div class="product-meta">
                                                <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
                                                <?php do_action( 'woocommerce_after_shop_loop_item_title' ); ?>
                                            </div>
                                        </li>
                                    <?php endwhile; ?>
                                </ul>
                            </div>		
                        </div>
                
        <?php       endif;  
                    wp_reset_query(); // Remember to reset 
                }
            } 
        ?>
		
<!-- BEGIN #main-content -->
</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>